require 'data_mapper'
require 'dm-validations'
require 'date'

class Item
    include DataMapper::Resource

    property :id, Serial
    property :name, String, :required => true
    property :description, Text, :lazy => false
    property :reward, Float, :required => true
    property :date, Date, :default => Date::today
    property :reported, Boolean, :required => true
    property :found, Boolean, :required => true
    property :archived, Boolean, :required => true
    property :match_name, String, :default => ""
    belongs_to :user
    has n, :tags, :through => Resource

    def to_json(args=nil)
        super :methods=>[:tags]
    end

end
